package JavaSE.CODE.javaIO;

import java.io.FileInputStream;
import java.io.FileOutputStream;

public class FileCopyDemo {
    public static void main(String[] args) throws Exception{
        //创建输入输出对象
        FileInputStream fileInputStream = new FileInputStream("D:\\fileInput.txt");
        FileOutputStream fileOutputStream = new FileOutputStream("D:\\fileOutput.txt");

        //1、创建缓冲区，通常写法是1024*n，表示nk大小的缓冲区
        byte[] bt = new byte[1024*2];
        //2、结束标志，当返回-1的时候，就已经终止了
        int count = 0;
        //3、从文件读入到缓冲区，再从缓冲区写回到文件中
        while((count=fileInputStream.read(bt))!=-1){
            //防止多写
            fileOutputStream.write(bt,0,count);
        }

        //3、关闭输入输出
        fileInputStream.close();
        fileOutputStream.close();
        System.out.println("over");


    }
}
